Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use unsigned integers only #8

Merged
merged 3 commits into from
Apr 12, 2024
Merged

feat: use unsigned integers only #8

merged 3 commits into from
Apr 12, 2024

Conversation

kyriediculous
Copy link
Member

@kyriediculous kyriediculous commented Apr 12, 2024

We can use our formula below with unsigned integers only

(((u + x)*k - U + u)*((U + x)/L)**k + (-k*u + U - u)*(U/L)**k)*(S + U)/(k*(1 + k)*(s + u))

in this formula (-k*u + U -u) can be rewritten as U-(k+1)*u

if U < (k+1*u) then we must do (k+1)*u - Uand subtract that from the first part of the sum in the nominator
else we use the initial formula

@0xnmna
Copy link
Contributor

0xnmna commented Apr 12, 2024

I suppose you mean if U < (k+1)*u instead of U < (k+1*u)?

So to clarify:

a = ((u + x)*k - U + u)  *  ((U + x)/L)**k
c = (S + U) / (k*(1 + k)*(s + u))

if ( U >= (k+1)*u ) {
    b = ( U - u(k+1) ) * (U/L)**k
    result = (a + b)*c

} else {
    b = ( u(k+1) - U ) * (U/L)**k
    result = (a - b)*c
}

Right?

@0xnmna 0xnmna requested review from 0xnmna and removed request for nmboavida April 12, 2024 16:16
src/Swap.sol Outdated Show resolved Hide resolved
@kyriediculous kyriediculous merged commit a7360d0 into main Apr 12, 2024
2 checks passed
@kyriediculous kyriediculous deleted the nv/unsigned-only branch April 12, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants